//package com.liuguang.gateway.controller;
//
//import com.liuguang.api.picture.PictureService;
//import com.liuguang.common.pojo.CommonResult;
//import org.apache.commons.lang3.ObjectUtils;
//import org.apache.dubbo.config.annotation.DubboReference;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.web.bind.annotation.PostMapping;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RequestMethod;
//import org.springframework.web.bind.annotation.RestController;
//import org.springframework.web.multipart.MultipartFile;
//
//import javax.servlet.ServletException;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.Part;
//import java.io.*;
//import java.util.Collection;
//
///**
// * @ClassName: PictureController
// * @Description：处理图片的上传:直接上传到7牛云，但是采用那种方式的上传？ 采用客户端直传，不能控制客户端传的是什么
// * 采用经过本地服务器的上传：当上传多个文件的时候会出现请求过大不能上传的问题吗？
// *
// * 分布式下文件上传：
// * 1、网关转发：
// *  controller放在网关地方，但是参数就不能传request，这个文件怎么传给 其他服务呢？
// *  2、controller 放在各个微服务中
// *  权限怎么控制？上传图片的接口是都可以调的
// * @Author: wanghr
// * Date: 11:15 AM 2020/10/22
// * Version: 1.0
// */
//@RestController
//@RequestMapping("/picture/")
//public class PictureController {
//    private static final Logger logger = LoggerFactory.getLogger(PictureController.class);
//
//    @DubboReference(timeout = 40000)
//    private PictureService pictureService;
//
//    /**
//     * 客户端直传的方式：获取上传token
//     */
//    @RequestMapping("getUpToken")
//    public CommonResult getUpToken(HttpServletRequest request) {
//        return pictureService.getUpToken();
//    }
//
//    //    @PostMapping("upload")
////    public CommonResult upload(MultipartFile file) {
////        String originalFilename = file.getOriginalFilename();
////        System.out.println("originalFilename = " + originalFilename);
////        InputStream inputStream = null;
////        try {
////            inputStream = fileile.getInputStream();
////        } catch (IOException e) {
////            e.printStackTrace();
////        }
////        return pictureService.upLoadToQiNiu(inputStream);
////    }
//
////    @PostMapping("upload")
//    @RequestMapping(value = "upload", method = RequestMethod.POST)
//    public CommonResult upload(HttpServletRequest request) {
//        try {
//            File file = new File("/Users/liuguang/Desktop/a.jpg");
//            Part part = request.getPart("tupian");
//            System.out.println(part.getName());
//            System.out.println(part.getSubmittedFileName());
//
//            InputStream inputStream = part.getInputStream();
//            part.write("/Users/liuguang/Desktop/a1.jpg");
//
//
////            pictureService.upLoadToQiNiu()
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
//
//        return CommonResult.success();
//    }
//}
